#ifndef INTERCAL_OUT_IO_H
#define INTERCAL_OUT_IO_H
#include "rclcpp/rclcpp.hpp"

class IntervalOutIo
{
public:
    struct TargetLevel{
        bool level = 0;
        int addr_index = 0;
    };
    IntervalOutIo() = default;
    explicit IntervalOutIo(rclcpp::Clock::SharedPtr clock);
    // IntervalOutIo(const uint32_t addr_index ,const int on_time, const int off_time);
    IntervalOutIo(rclcpp::Clock::SharedPtr clock, const uint32_t addr_index, const int on_time, const int off_time);

    ~IntervalOutIo();

    void start();

    void stop();

    bool intervalOutput(TargetLevel &set_io);

private:
    uint32_t m_addr_index;
    bool m_cur_level;
    bool m_stop;
    bool m_set_last_level;
    int m_on_time;
    int m_off_time;
    rclcpp::Time m_start_time;
    rclcpp::Clock::SharedPtr clock_;

private:
    void init();
};

#endif